home *** CD-ROM | disk | FTP | other *** search
- /*
- * procDebugRegs.c --
- *
- * Convert registers between the format expected by the ptrace system
- * call and that of the Sprite Proc_Debug call.
- *
- * Copyright 1989 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
- #endif /* not lint */
-
- #include "sprite.h"
- #include "status.h"
- #include <sys/types.h>
- #include "sys/ptrace.h"
- #include <errno.h>
- #include <proc.h>
- #include <signal.h>
- #include <sys/wait.h>
- #include "machine/reg.h"
- #include "procDebugRegs.h"
-
-
- /*
- *----------------------------------------------------------------------
- *
- * procDebugToPtraceRegs --
- *
- * Convert registers from a proc debug format to a ptrace format.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- void
- procDebugToPtraceRegs(regStatePtr, ptraceRegsPtr)
- Mach_RegState *regStatePtr; /* Register state as returned by
- * the PROC_GET_DBG_STATE argument
- * to Proc_Debug. */
- char *ptraceRegsPtr; /* Memory to put ptrace format of
- * registers. */
-
- {
- register struct pt_regset *regs = (struct pt_regset *) ptraceRegsPtr;
-
- regs->pr_eax = regStatePtr->userRegs.trapEAX;
- regs->pr_ebx = regStatePtr->userRegs.trapEBX;
- regs->pr_ecx = regStatePtr->userRegs.trapECX;
- regs->pr_edx = regStatePtr->userRegs.trapEDX;
- regs->pr_esi = regStatePtr->userRegs.trapESI;
- regs->pr_edi = regStatePtr->userRegs.trapEDI;
- regs->pr_ebp = (unsigned int) regStatePtr->userRegs.trapEBP;
- regs->pr_esp = (unsigned int) regStatePtr->userRegs.trapESP;
- regs->pr_eip = (unsigned int) regStatePtr->userRegs.trapEIP;
- regs->pr_flags = regStatePtr->userRegs.trapFlags;
- regs->pr_fpu = regStatePtr->userFPURegs;
- return;
- }
-
-
- /*
- *----------------------------------------------------------------------
- *
- * ptraceToProcDebugRegs --
- *
- * Convert registers from a ptrace format to a proc debug format.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- void
- ptraceToProcDebugRegs(ptraceRegsPtr, regStatePtr)
- char *ptraceRegsPtr; /* Memory image of ptrace format of
- * registers. */
- Mach_RegState *regStatePtr; /* Register state as used by Proc_Debug */
-
- {
- register struct pt_regset *regs = (struct pt_regset *) ptraceRegsPtr;
-
- regStatePtr->userRegs.trapEAX = regs->pr_eax;
- regStatePtr->userRegs.trapEBX = regs->pr_ebx;
- regStatePtr->userRegs.trapECX = regs->pr_ecx;
- regStatePtr->userRegs.trapEDX = regs->pr_edx;
- regStatePtr->userRegs.trapESI = regs->pr_esi;
- regStatePtr->userRegs.trapEDI = regs->pr_edi;
- regStatePtr->userRegs.trapEBP = (Address) regs->pr_ebp;
- regStatePtr->userRegs.trapESP = (Address) regs->pr_esp;
- regStatePtr->userRegs.trapEIP = (Address) regs->pr_eip;
- regStatePtr->userRegs.trapFlags = regs->pr_flags;
- regStatePtr->userFPURegs = regs->pr_fpu;
- return;
- }
-
-